package com.joker.microstoremanager.repository;

import com.joker.microstoremanager.model.GoodsTagRelation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface GoodsTagRepository extends JpaRepository<GoodsTagRelation,Long>{
    @Modifying
    @Query(nativeQuery = true,value = "delete from GOODS_TAG_RELATION where TAG_ID in (select id from tag where SHOP_ID = ?1)")
    void deleteByShop(Long shopId);
    @Modifying
    @Query(value = "delete from GoodsTagRelation g where g.goods.id = ?1")
    void deleteByGoodsId(Long goodsId);

    @Modifying
    @Query(value = "delete from GoodsTagRelation g where g.tag.id = ?1")
    void deleteByTagId(Long tagId);
}
